package org.reenscape.packet;
import org.reenscape.model.*;
import org.reenscape.skill.*;
import org.reenscape.updater.*;
public class PacketItemOnOther {


		/**
		* Using one item on another.
		*/
		public void ItemOnItem(PacketParser p3){
			int WithSlot = p3.inStream.readUnsignedWord();
			int UsedSlot = p3.inStream.readUnsignedWordA();
			int InterfaceA = p3.inStream.readUnsignedWord();
			int InterfaceB = p3.inStream.readUnsignedWord();
			int With = p3.playerItems[WithSlot]-1;
			int Used = p3.playerItems[UsedSlot]-1;
			boolean valid = p3.check(With);
			boolean valid2 = p3.check(Used);
			
					if(!valid || !valid2){
						Flagger.flag(p3);
						return;
					}
			
			//Herblore
			if(Used == 227) Skill.herblore.VialOnHerb(With, p3);
			else if(With == 227) Skill.herblore.VialOnHerb(Used, p3);
			Skill.herblore.Finish(With, Used, p3);
			Skill.herblore.Finish(Used, With, p3);
			
			//Fletching
			if(Used == 946 && With == 1511) Skill.fletching.CutLogs(p3);
			else if(With == 946 && Used == 1511) Skill.fletching.CutLogs(p3);
			if(Used == 5605) Skill.fletching.ChooseBow(With, p3);
			else if(With == 5605) Skill.fletching.ChooseBow(Used, p3);
			if(Used == 1777) Skill.fletching.StringBow(With, p3);
			else if(With == 1777) Skill.fletching.StringBow(Used, p3);
			
			//Firemaking
			if(Used == 590 &&(With == 1511 || With == 1513 || With == 1515 || With == 1517 || With == 1519 || With == 1521 || With == 2862 || With == 6332 || With == 6333)) Skill.firemaking.Light(With, p3);
			else if(With == 590 &&(Used == 1511 || Used == 1513 || Used == 1515 || Used == 1517 || Used == 1519 || Used == 1521 || Used == 2862 || Used == 6332 || Used == 6333)) Skill.firemaking.Light(Used, p3);
			
			//Crafting
			if(Used == 1755) Skill.crafting.cut(With, p3);
			else if(With == 1755) Skill.crafting.cut(Used, p3);
		}
		
		/**
		* Using an item on an Object.
		*/
		public void ItemOnObject(PacketParser p3){
			int Interface = p3.inStream.readUnsignedWordA();
			int ObjID = p3.inStream.readSignedWordBigEndian();
			int ObjY = p3.inStream.readUnsignedWordBigEndianA();
			int Slot = p3.inStream.readUnsignedWordBigEndian();
			int ObjX = p3.inStream.readUnsignedWordBigEndianA();
			int ItemID = p3.inStream.readUnsignedWord();
			boolean valid = p3.check(ItemID);
			
					if(!valid){
						Flagger.flag(p3);
						return;
					}
			
			//Smithing
			if((ItemID == 2349 || ItemID == 2351 || ItemID ==2353 || ItemID == 2359 || ItemID == 2361 || ItemID == 2363) && (ObjID == 2782 || ObjID == 2783 || ObjID == 4306 || ObjID == 6150)) Skill.smithing.initSmithing(ItemID, p3);
			if((ObjID == 11666 || ObjID == 2781 || ObjID == 2785 || ObjID == 2966 || ObjID == 3044 || ObjID == 3294 || ObjID == 3413 || ObjID == 4304 || ObjID == 3405 || ObjID == 6189 || ObjID == 6190) && (ItemID == 436 || ItemID == 438 || ItemID == 440 || ItemID == 442 || ItemID == 444 || ItemID == 447 || ItemID == 449 || ItemID == 451 || ItemID == 668 || ItemID == 2892)){ Skill.smithing.SmeltingMain(p3, 1, ItemID); p3.sendMessage("You start smelting the ores...");} 
			
			//Runecrafting
			if(ItemID == 1438 &&(ObjID == 2452)) { Skill.runecrafting.Ruins("Air", 2845, 4832, p3); } /* Air Rune Altar */
			if(ItemID == 1448 &&(ObjID == 2453)) { Skill.runecrafting.Ruins("Mind", 2796, 4818, p3); } /* Mind Rune Altar */
			if(ItemID == 1444 &&(ObjID == 2454)) { Skill.runecrafting.Ruins("Water", 2713, 4836, p3); } /* Water Rune Altar */
			if(ItemID == 1440 &&(ObjID == 2455)) { Skill.runecrafting.Ruins("Earth", 2660, 4839, p3); } /* Earth Rune Altar */
			if(ItemID == 1442 &&(ObjID == 2456)) { Skill.runecrafting.Ruins("Fire", 2584, 4836, p3); } /* Fire Rune Altar */
			if(ItemID == 1446 &&(ObjID == 2457)) { Skill.runecrafting.Ruins("Body", 2527, 4833, p3); } /* Body Rune Altar */
			if(ItemID == 1454 &&(ObjID == 2458)) { Skill.runecrafting.Ruins("Cosmic", 2143, 4835, p3); } /* Cosmic Rune Altar */
			if(ItemID == 1458 &&(ObjID == 2459)) { Skill.runecrafting.Ruins("Law", 2464, 4834, p3); } /* Law Rune Altar */
			if(ItemID == 1462 &&(ObjID == 2460)) { Skill.runecrafting.Ruins("Nature", 2398, 4841, p3); } /* Nature Rune Altar */
			
			//Cooking
				/*FIRE COOKING*/
			if(ObjID == 2732) Skill.cooking.cook(true, ItemID, p3);
				/*STOVE COOKING*/
			if(ObjID == 2728 || ObjID == 12102 || ObjID == 8712 || ObjID == 12269) Skill.cooking.cook(false, ItemID, p3);
		}
		
		/**
		* Using an item on another player. Eg. Crackers.
		*/
		public void ItemOnPlayer(PacketParser p3){
			int PlayerSlot = p3.inStream.readSignedWord();
			int ID = p3.inStream.readSignedWord();
			int Slot = p3.inStream.readSignedWordBigEndian();
			boolean valid = p3.check(ID);
			if(PlayerSlot > ClientUpdater.maxPlayers) return; 
			PacketParser p4 = (PacketParser) ClientUpdater.players[PlayerSlot];
			
				if(p4 == null){
					Flagger.flag(p3);
					return;
				}
				if(!valid){
					Flagger.flag(p3);
					return;
				}
		}
}